package leetcode.N901_N1000;

public class N933 {

}

class RecentCounter {

    int [] queue;
    int head;
    int tail;


    public RecentCounter() {
        this.queue = new int[10001];
        this.head = 0;
        this.tail = 0;

    }

    public int ping(int t) {
        // 先把当前入参入队
        queue[tail++] = t;
        int limit = t - 3000;
        while (queue[head] < limit) {
            // 循环判断队头是否已经不符合条件 如果不符合 则移除
            head++;
        }
        return tail - head;
    }

}

/**
 * Your RecentCounter object will be instantiated and called as such:
 * RecentCounter obj = new RecentCounter();
 * int param_1 = obj.ping(t);
 */
